package com.lap.auth.domain.dept.service;

import com.lap.auth.domain.dept.Dept;
import com.lap.auth.domain.dept.repository.DeptRepository;
import com.lap.auth.domain.shared.errors.UserError;
import com.lap.framework.exception.BizException;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
public class DeptValidator {

  private final DeptRepository deptRepository;

  public Dept assertDeptExists(Integer id) {
    return deptRepository
        .findById(id)
        .orElseThrow(() -> BizException.newBiz(UserError.DEPT_NOT_FOUND));
  }
}
